/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package reportcenter.support.custom.command;

import org.springframework.richclient.application.ViewDescriptor;
import org.springframework.richclient.command.support.ApplicationWindowAwareCommand;

/**
 *
 * @author renan
 */
public class ShowViewCommand extends ApplicationWindowAwareCommand {
    private ViewDescriptor viewDescriptor;

    
    public ShowViewCommand(ViewDescriptor viewDescriptor) {
        setViewDescriptor(viewDescriptor);
        setEnabled(true);
    }

    public final void setViewDescriptor(ViewDescriptor viewDescriptor) {
        setId(viewDescriptor.getId()); 
        setLabel(viewDescriptor.getShowViewCommandLabel());
        setIcon(viewDescriptor.getIcon());
        setCaption(viewDescriptor.getCaption());
        this.viewDescriptor = viewDescriptor;
    }

    protected void doExecuteCommand() {
        getApplicationWindow().getPage().showView(viewDescriptor);
    }


}
